<?php
/**
 * Created by PhpStorm.
 * User: THINK
 * Date: 2017/8/25
 * Time: 14:56
 */
namespace Home\Controller;

use Think\Controller;

class ProductDisplayController extends Controller
{
    public function index(){
        $indexs = M('announce');
        $lists = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('lists',$lists);
        $index = M('product');
        $list = $index->select();
        $this->assign('list',$list);
        $this->display();
    }
    public function indexs(){
        $indexs = M('announce');
        $lists = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('lists',$lists);
        $index = M('product');
        $list = $index->where("cid = 6")->select();
        $this->assign('list',$list);
        $this->display();
    }
    public function indexss(){
        $indexs = M('announce');
        $lists = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('lists',$lists);
        $index = M('product');
        $list = $index->where("cid = 7")->select();
        $this->assign('list',$list);
        $this->display();
    }

    public function show(){
        $indexs = M('announce');
        $listss = $indexs->order('posttime desc')->limit(0,1)->select();
        $this->assign('listss',$listss);
        $id  = I('id');
        $index = M('product');
        $list = $index->find($id);

        $listn = $index->where('id <'.$id)->order('id desc')->limit(1)->find();
        $listl = $index->where('id >'.$id)->order('id asc')->limit(1)->find();

        $preId = $listn['id'];
        if ($index->min('id')>=$listn['id']){
            $preId="";
        }

        $nextId = $listl['id'];
        if ($index->max('id')<=$listl['id']){
            $nextId="";
        }

        $lists = $index->select();
        $this->assign('list',$list);
        $this->assign('lists',$lists);
        $this->assign('listn',$listn);
        $this->assign('listl',$listl);

        $this->assign('preId',$preId);
        $this->assign('nextId',$nextId);
        $this->display();
    }
}